﻿using UnityEngine;
using System.Collections;

//基础玩家-》真人玩家，AI玩家，网络玩家
public abstract class BasePlayerModel  {

    abstract public void OnChangeSide ( );

    /// <summary>
    /// 搬一步棋的棋子
    /// </summary>
    /// <param name="move">走棋步骤</param>
    /// <returns>返回原来目标格子上的棋子</returns>
   virtual public int MovePiece (int move) {
       return chessPlayerModel.MovePiece(move, 0);
    }

    /// <summary>
    /// 撤消搬一步棋的棋子，该方法要传入走棋的步骤，以及该走棋步骤下的目标位置上的棋子。
    /// 先将该棋子搬到初始位置，如果该步骤下的目标位置上的棋子不为空，即： 是吃子走法时，
    /// 把被吃掉的棋子重新搬到该位置，以此来实现撤销搬一步棋的功能。
    /// </summary>
    /// <param name="move">走棋步骤</param>
    /// <param name="pcCaptured">原来目标格子上的棋子</param>
    virtual public void UndoMovePiece (int move, int pcCaptured) {
        chessPlayerModel.UndoMovePiece(move, pcCaptured);
    }

    protected ChessGameModel chessGameModel;
    /// <summary>
    /// 我是哪一边的
    /// </summary>
    protected RedBlackSide mySide;

    protected ChessBoardModel chessBoardModel;
    protected ChessPlayerModel chessPlayerModel;

    public BasePlayerModel (ChessGameModel chessGameModel, RedBlackSide mySide) {
        this.chessGameModel = chessGameModel;
        this.mySide = mySide;

        Init( );
    }

    void Init ( ) {
        chessBoardModel = chessGameModel.ChessBoardModel;

        if (mySide == RedBlackSide.RED) {
            chessPlayerModel = chessGameModel.RedPlayer;
        } else {
            chessPlayerModel = chessGameModel.BlackPlayer;
        }
    }

}
